import amaret.freestyle.board.UserLed;

@Template("./Board.xdt")
module Board inherits embios.interfaces.IBoard {

internal:

    Void flash( Int period, Int count );
    
}

implementation {

    function startup()
    {
        flash(50000, 2);
    }

    function shutdown( stat )
    {
        UserLed.on();
    }

    function flash( period, count )
    {
        volatile UInt i;    /* volatile to prevent optimization */
        while (count) {
            UserLed.on();
            for (i = period; i != 0; i--) ;
            UserLed.off();
            for (i = period; i != 0; i--) ;
            if (count > 0) { /* go forever if count < 0 */
                count--;
            }
        }
    }

}
